package fatworm.concept;

import fatworm.util.Lib;

/**
 * arithmetic operator
 */
public class ArithOp {
	private int oper;
	private ArithOp( int oper ){
		this.oper = oper;
	}
	
	/**
	 * get the integer representation of arithmetic operator
	 * @return the integer representation
	 */
	public int getOper(){
		return oper;
	}
	
	public String toString(){
		return toString(oper);
	}
	
	/** 
	 * get the string representation of relational operator
	 * @param oper	integer representation
	 * @return	string representation
	 */
	public static String toString( int oper ){
		switch( oper ){
			case O_ADD: return "+";
			case O_SUB: return "-";
			case O_MUL: return "*";
			case O_DIV: return "/";
			case O_MOD: return "%";
			default	: Lib.assertNotReached(); return null;
		}
	}
	public static final int O_ADD = 0 , O_SUB = 2 , O_MUL = 3 , O_DIV = 4 , O_MOD = 5;  	
	public static final ArithOp ADD = new ArithOp( O_ADD );
	public static final ArithOp SUB = new ArithOp( O_SUB );
	public static final ArithOp MUL = new ArithOp( O_MUL );
	public static final ArithOp DIV = new ArithOp( O_DIV );
	public static final ArithOp MOD = new ArithOp( O_MOD );
}
